<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>SerializationUtils (Apache Commons Lang 3.3.2 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="SerializationUtils (Apache Commons Lang 3.3.2 API)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/SerializationUtils.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/commons/lang3/StringEscapeUtils.html" title="class in org.apache.commons.lang3"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/commons/lang3/SerializationUtils.html" target="_top">Frames</a></li>
<li><a href="SerializationUtils.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.commons.lang3</div>
<h2 title="Class SerializationUtils" class="title">Class SerializationUtils</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.commons.lang3.SerializationUtils</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <span class="strong">SerializationUtils</span>
extends <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre>
<div class="block"><p>Assists with the serialization process and performs additional functionality based
 on serialization.</p>

 <ul>
 <li>Deep clone using serialization
 <li>Serialize managing finally and IOException
 <li>Deserialize managing finally and IOException
 </ul>

 <p>This class throws exceptions for invalid <code>null</code> inputs.
 Each method documents its behaviour in more detail.</p>

 <p>#ThreadSafe#</p></div>
<dl><dt><span class="strong">Since:</span></dt>
  <dd>1.0</dd>
<dt><span class="strong">Version:</span></dt>
  <dd>$Id: SerializationUtils.java 1583482 2014-03-31 22:54:57Z niallp $</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!--   -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../org/apache/commons/lang3/SerializationUtils.html#SerializationUtils()">SerializationUtils</a></strong>()</code>
<div class="block">SerializationUtils instances should NOT be constructed in standard programming.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;T extends <a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&gt;&nbsp;<br>T</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/lang3/SerializationUtils.html#clone(T)">clone</a></strong>(T&nbsp;object)</code>
<div class="block">Deep clone an <code>Object</code> using serialization.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;T</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/lang3/SerializationUtils.html#deserialize(byte[])">deserialize</a></strong>(byte[]&nbsp;objectData)</code>
<div class="block">
 Deserializes a single <code>Object</code> from an array of bytes.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;T</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/lang3/SerializationUtils.html#deserialize(java.io.InputStream)">deserialize</a></strong>(<a href="http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;inputStream)</code>
<div class="block">
 Deserializes an <code>Object</code> from the specified stream.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static &lt;T extends <a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&gt;&nbsp;<br>T</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/lang3/SerializationUtils.html#roundtrip(T)">roundtrip</a></strong>(T&nbsp;msg)</code>
<div class="block">Performs a serialization roundtrip.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/lang3/SerializationUtils.html#serialize(java.io.Serializable)">serialize</a></strong>(<a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&nbsp;obj)</code>
<div class="block">Serializes an <code>Object</code> to a byte array for
 storage/serialization.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/commons/lang3/SerializationUtils.html#serialize(java.io.Serializable, java.io.OutputStream)">serialize</a></strong>(<a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&nbsp;obj,
         <a href="http://docs.oracle.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;outputStream)</code>
<div class="block">Serializes an <code>Object</code> to the specified stream.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!--   -->
</a>
<h3>Constructor Detail</h3>
<a name="SerializationUtils()">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>SerializationUtils</h4>
<pre>public&nbsp;SerializationUtils()</pre>
<div class="block"><p>SerializationUtils instances should NOT be constructed in standard programming.
 Instead, the class should be used as <code>SerializationUtils.clone(object)</code>.</p>

 <p>This constructor is public to permit tools that require a JavaBean instance
 to operate.</p></div>
<dl><dt><span class="strong">Since:</span></dt>
  <dd>2.0</dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="clone(java.io.Serializable)">
<!--   -->
</a><a name="clone(T)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clone</h4>
<pre>public static&nbsp;&lt;T extends <a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&gt;&nbsp;T&nbsp;clone(T&nbsp;object)</pre>
<div class="block"><p>Deep clone an <code>Object</code> using serialization.</p>

 <p>This is many times slower than writing clone methods by hand
 on all objects in your object graph. However, for complex object
 graphs, or for those that don't support deep cloning this can
 be a simple alternative implementation. Of course all the objects
 must be <code>Serializable</code>.</p></div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - the type of the object involved</dd><dt><span class="strong">Parameters:</span></dt><dd><code>object</code> - the <code>Serializable</code> object to clone</dd>
<dt><span class="strong">Returns:</span></dt><dd>the cloned object</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3">SerializationException</a></code> - (runtime) if the serialization fails</dd></dl>
</li>
</ul>
<a name="roundtrip(java.io.Serializable)">
<!--   -->
</a><a name="roundtrip(T)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>roundtrip</h4>
<pre>public static&nbsp;&lt;T extends <a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&gt;&nbsp;T&nbsp;roundtrip(T&nbsp;msg)</pre>
<div class="block">Performs a serialization roundtrip. Serializes and deserializes the given object, great for testing objects that
 implement <a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io"><code>Serializable</code></a>.</div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - the type of the object involved</dd><dt><span class="strong">Parameters:</span></dt><dd><code>msg</code> - the object to roundtrip</dd>
<dt><span class="strong">Returns:</span></dt><dd>the serialized and deseralized object</dd><dt><span class="strong">Since:</span></dt>
  <dd>3.3</dd></dl>
</li>
</ul>
<a name="serialize(java.io.Serializable, java.io.OutputStream)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>serialize</h4>
<pre>public static&nbsp;void&nbsp;serialize(<a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&nbsp;obj,
             <a href="http://docs.oracle.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;outputStream)</pre>
<div class="block"><p>Serializes an <code>Object</code> to the specified stream.</p>

 <p>The stream will be closed once the object is written.
 This avoids the need for a finally clause, and maybe also exception
 handling, in the application code.</p>

 <p>The stream passed in is not buffered internally within this method.
 This is the responsibility of your application if desired.</p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - the object to serialize to bytes, may be null</dd><dd><code>outputStream</code> - the stream to write to, must not be null</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>outputStream</code> is <code>null</code></dd>
<dd><code><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3">SerializationException</a></code> - (runtime) if the serialization fails</dd></dl>
</li>
</ul>
<a name="serialize(java.io.Serializable)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>serialize</h4>
<pre>public static&nbsp;byte[]&nbsp;serialize(<a href="http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>&nbsp;obj)</pre>
<div class="block"><p>Serializes an <code>Object</code> to a byte array for
 storage/serialization.</p></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - the object to serialize to bytes</dd>
<dt><span class="strong">Returns:</span></dt><dd>a byte[] with the converted Serializable</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3">SerializationException</a></code> - (runtime) if the serialization fails</dd></dl>
</li>
</ul>
<a name="deserialize(java.io.InputStream)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>deserialize</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;T&nbsp;deserialize(<a href="http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;inputStream)</pre>
<div class="block"><p>
 Deserializes an <code>Object</code> from the specified stream.
 </p>
 
 <p>
 The stream will be closed once the object is written. This avoids the need for a finally clause, and maybe also
 exception handling, in the application code.
 </p>
 
 <p>
 The stream passed in is not buffered internally within this method. This is the responsibility of your
 application if desired.
 </p>
 
 <p>
 If the call site incorrectly types the return value, a <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/ClassCastException.html?is-external=true" title="class or interface in java.lang"><code>ClassCastException</code></a> is thrown from the call site.
 Without Generics in this declaration, the call site must type cast and can cause the same ClassCastException.
 Note that in both cases, the ClassCastException is in the call site, not in this method.
 </p></div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - the object type to be deserialized</dd><dt><span class="strong">Parameters:</span></dt><dd><code>inputStream</code> - the serialized object input stream, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>the deserialized object</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>inputStream</code> is <code>null</code></dd>
<dd><code><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3">SerializationException</a></code> - (runtime) if the serialization fails</dd></dl>
</li>
</ul>
<a name="deserialize(byte[])">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>deserialize</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;T&nbsp;deserialize(byte[]&nbsp;objectData)</pre>
<div class="block"><p>
 Deserializes a single <code>Object</code> from an array of bytes.
 </p>
 
 <p>
 If the call site incorrectly types the return value, a <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/ClassCastException.html?is-external=true" title="class or interface in java.lang"><code>ClassCastException</code></a> is thrown from the call site.
 Without Generics in this declaration, the call site must type cast and can cause the same ClassCastException.
 Note that in both cases, the ClassCastException is in the call site, not in this method.
 </p></div>
<dl><dt><span class="strong">Type Parameters:</span></dt><dd><code>T</code> - the object type to be deserialized</dd><dt><span class="strong">Parameters:</span></dt><dd><code>objectData</code> - the serialized object, must not be null</dd>
<dt><span class="strong">Returns:</span></dt><dd>the deserialized object</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://docs.oracle.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>objectData</code> is <code>null</code></dd>
<dd><code><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3">SerializationException</a></code> - (runtime) if the serialization fails</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/SerializationUtils.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/commons/lang3/StringEscapeUtils.html" title="class in org.apache.commons.lang3"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/commons/lang3/SerializationUtils.html" target="_top">Frames</a></li>
<li><a href="SerializationUtils.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2001&#x2013;2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>
